var app = getApp()
var getMyCouponUrl = "couponsApi/getMyCoupon";

Page({
  data: {
    // 页面配置  
    winWidth: 0,
    winHeight: 0,
    currentTab: 0,

  },
  onLoad: function () {
    var that = this;
    // 获取系统信息 
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });


    wx.request({
      url: app.globalData.requestUrl + getMyCouponUrl,
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      data: {//这里写你要请求的参数
        userID: app.globalData.userId,
      },
      success: function (res) {
        wx.hideLoading();
        console.log(res);//打印日志
        var wsynum = res.data.data.wsylist.length;
        var ysynum = res.data.data.ysylist.length;
        var ygqnum = res.data.data.ygqlist.length;
        console.log(ysynum)
        that.setData({
          wsylist: res.data.data.wsylist,
          ysylist: res.data.data.ysylist,
          ygqlist: res.data.data.ygqlist,
          wsynum: wsynum,
          ysynum: ysynum,
          ygqnum: ygqnum
        })
      }
    })
    
  },
  // 滑动切换tab 
  bindChange: function (e) {
    var that = this;
    that.setData({ currentTab: e.detail.current });
  },
  // 点击tab切换 
  swichNav: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  }
}) 